package com.yiwei.hdb.api.requestInfo;

import com.yiwei.hdb.api.Api;
import com.yiwei.hdb.api.bean.LoginBean;
import com.yiwei.hdb.api.callback.LoginContract;
import com.yiwei.hdb.api.callback.PointRuleContract;
import com.yiwei.hdb.util.Network;
import com.yiwei.hdb.util.RxLifeUtil;
import com.yiwei.hdb.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class PointRuleRequest extends BaseRequest<PointRuleContract.View> implements PointRuleContract.Presenter<PointRuleContract.View> {

    public static PointRuleRequest create() {
        return new PointRuleRequest();
    }


    @Override
    public void getRuleText() {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail);
            return;
        }
        mView.onRequestStart();
        Api.api_service.getPointRule().compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();
                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getRuleTextSuccess(result);
                });
    }
}
